package com.isoftstone.framework.controller;


import com.isoftstone.common.constant.Constants;
import com.isoftstone.common.utils.text.Convert;
import com.isoftstone.framework.PagePlugin;
import com.isoftstone.framework.domain.Page;


import com.isoftstone.framework.domain.PageData;

import com.isoftstone.project.system.domain.SysUser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * 修改时间：2015、12、11
 */
public class BaseController {


	private Log logger = LogFactory.getLog(PagePlugin.class);

	private static final long serialVersionUID = 6357869213649815390L;

	/** new PageData对象
	 * @return
	 */
	public PageData getPageData(){
		return new PageData(this.getRequest());
	}

	/**得到ModelAndView
	 * @return
	 */
	public ModelAndView getModelAndView(){
		return new ModelAndView();
	}

	/**得到request对象
	 * @return
	 */
	public HttpServletRequest getRequest() {
		HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
		return request;
	}

	/**得到分页列表的信息
	 * @return
	 */
	public Page getPage(){
		return new Page();
	}

	public String get32UUID(){
		return Convert.get32UUID();
	}
	protected Session getSession() {
		return SecurityUtils.getSubject().getSession();
	}


	protected SysUser getUser() {
		return ((SysUser) this.getSession().getAttribute(Constants.SESSION_USER));
	}

}
